Building Dynamic Web 2.0 Websites with Ruby on Rails by A. P. Rajshekhar

Building Dynamic Web 2.0 Websites with Ruby on Rails by A. P. Rajshekhar

Author:A. P. Rajshekhar [A P Rajshekhar ]
Language: eng
Format: epub
Publisher: Packt Publishing


So we have created the two required lists. Now let us display it to the user.

Refining the View

The first step in displaying both the lists is to create a template in the app/views/users folder. Let us name it display_assign.rhtml. It will contain code to show two combo boxes—one for showing the users and another for showing the roles. Apart from that we need to give the submit button to submit the selected values to the Controller. The code is identical to what you have seen for displaying the list of genres in the 'New Tale' page. The following is the code:

<h1>Assign Role</h1> <% form_tag :action => 'assign' do %> <p><label for="user_user_name">User<br/> <select name="user"> <% @users.each do |user| %> <option value="<%= user.id %>"> <%= user.user_name %> </option> <% end %> </select> </p> <p><label for="role_role_name">Role<br/> <select name="role"> <% @roles.each do |role| %> <option value="<%= role.id %>"> <%= role.name %> </option> <% end %> </select> </p> <%= submit_tag "Assign Role" %> <% end %> <%= link_to 'Back', :action => 'list' %>



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.